package tech.dx.springdb.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.dx.springdb.entity.LearningStatus;
import tech.dx.springdb.respository.LearningStatusRepository;
import tech.dx.springdb.service.LearningStatusService;

import java.util.Optional;

/**
 * @ClassName LearningStatusServiceImpl
 * @Description TODO
 * @Author daoxuan
 * @Date 2019/4/1 12:19
 * @Version 1.0
 */
@Service
public class LearningStatusServiceImpl implements LearningStatusService {
    @Autowired
    private LearningStatusRepository learningStatusRepository;

    @Override
    public Optional<LearningStatus> getById(long id) {
        return learningStatusRepository.findById(id);
    }

    @Override
    public LearningStatus add(LearningStatus classtype) {
        return learningStatusRepository.save(classtype);
    }

    @Override
    public LearningStatus update(LearningStatus classtype) {
        return  add(classtype);
    }

    @Override
    public void del(long id) {
            learningStatusRepository.deleteById(id);
    }

    @Override
    public boolean isExitById(long id) {
        return getById(id).isPresent() ? true : false;
    }
}
